<?php
defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__));

final class Bootstrap {
    /**
     * Application model
     * @var Mage_Core_Model_App
     */
    static private $_app;

    static private $_mode;

    private static function load() {
        require_once ROOT_PATH . DIRECTORY_SEPARATOR .
            'library' .DIRECTORY_SEPARATOR .
            'core' . DIRECTORY_SEPARATOR .
            "Application.php";
        require_once ROOT_PATH . DIRECTORY_SEPARATOR .
            'library' .DIRECTORY_SEPARATOR .
            'core' . DIRECTORY_SEPARATOR .
            "Application" . DIRECTORY_SEPARATOR .
            self::$_mode . ".php";
        $class = "\\Core\\Application\\" . self::$_mode;
        return new $class();
    }

    public static function app($mode = 'web') {
        if (null === self::$_app) {
            self::$_mode = ucfirst($mode);
            self::$_app = self::load() ;
        }
        return self::$_app;
    }
}